package com.hellogood.yaohuo.server.dao;

import java.util.ArrayList;
import java.util.List;

import com.hellogood.yaohuo.shared.entity.Detail;

public class YhDetailDAO extends DetailDAO {

	@SuppressWarnings("unchecked")
	public List<Detail> searchDetail(String orgCode, String date) {
		List<Detail> list = new ArrayList<Detail>();
		String sql = "SELECT * FROM yhDetail WHERE orgCode in (" + orgCode + ") AND (rzDate IS NULL OR rzDate = '') AND CONVERT (120, timeMark) <= '" + date + "'";
		list = (List<Detail>) super.query(sql);
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<Detail> getYaohuohuizong(String quyuCode, String date) {
		List<Detail> list = new ArrayList<Detail>();
		String sql = "select distinct d.* from qyorg q, yhdetail d,yhform f where f.yhbillno = d.yhbillno and f.orgcode = q.orgcode and f.yhDate <= '" + date + "' and q.qycode = '" + quyuCode
				+ "' and f.status = 0 AND f.rzDate <> ''";
		if (quyuCode.equals("0")) {
			sql = "select distinct d.* from qyorg q, yhdetail d,yhform f where f.yhbillno = d.yhbillno and f.orgcode = q.orgcode and f.yhDate <= '" + date + "' and f.status = 0 AND f.rzDate <> ''";
		}
		list = (List<Detail>) super.query(sql);
		return list;
	}
}
